public class Find {
    // 二维数组中的查找
    // https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e?tpId=295&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%3FquestionJobId%3D10%26subTabName%3Donline_coding_page&dayCountBigMember=365%E5%A4%A9
    public boolean Find (int target, int[][] array) {
        // write code here
        int n = array.length, m = array[0].length;
        if (n == 0 || m == 0) {
            return false;
        }
        int row = 0, col = m-1;
        while (row < n && col >= 0) {
            int num = array[row][col];
            if (num == target) {
                return true;
            } else if (num > target) {
                col--;
            } else {
                row++;
            }
        }
        return false;
    }
}
